package com.serialcommunication.model;

import java.awt.Dimension;
import java.awt.Point;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JComponent;
import static com.serialcommunication.constants.GuiConfiguration.*;

import com.serialcommunication.interfaces.IBaseComponent;

public class ComponentRow {
	
	private List<IBaseComponent> list;
	
	private int heigth = 0;;
	private int insertX;
	private int y;
	
	public ComponentRow(int pX, int pY) {
		insertX = pX;
		y = pY;
		list = new ArrayList<IBaseComponent>();
	}
	
	public Point insert(IBaseComponent comp) {
		if (heigth < comp.getPanel().getHeight()) {
			heigth = comp.getPanel().getHeight();
		}
		list.add(comp);
		int xRetValue = insertX;
		insertX = insertX + comp.getPanel().getWidth() + PANEL_PANEL_PADDING_X;
		return new Point(xRetValue, y);
	}
	
	public Point insert(JComponent comp) {
		if (heigth < comp.getHeight()) {
			heigth = comp.getHeight();
			
		}
		
		int xRetValue = insertX;
		insertX = insertX + comp.getWidth() + PANEL_PANEL_PADDING_X;
		return new Point(xRetValue, y);
	}

	public int getHeigth() {
		return heigth;
	}

	public List<IBaseComponent> getList() {
		return list;
	}
}
